<template>
	<view>
		<u-navbar :border-bottom="false">
		</u-navbar>
		<view class="u-m-x-30">
			<text class="u-font-50 text-bold">添加好友</text>
		</view>
		<navigator url="/pages/friend/add" hover-class="none" class="search-bar u-p-20 u-m-x-30 u-m-t-20">
			<text class="iconfont icon-sousuo u-font-40"></text>
			<text class="u-font-32 u-m-l-6">搜索</text>
		</navigator>
		<navigator url="/pages/my/archive/qrcode" hover-class="none" class="u-flex u-row-center u-m-t-20">
			<text class="text-gray u-font-32">我的账号：{{userInfo.mobile}}</text>
			<text class="iconfont icon-erweima u-font-46 u-m-l-10"></text>
		</navigator>
		
		<view class="choice">
			<view class="item" @tap="scan">
				<view class="icon">
					<text class="cuIcon-scan u-font-60 text-blue"></text>
				</view>
				<view class="content">
					<view class="label">
						<text class="u-font-36 text-bold">扫一扫</text>
					</view>
					<view class="sub u-m-t-10">
						<text class="u-font-28">扫码二维码名片</text>
					</view>
				</view>
				<view class="arrow">
					<text class="iconfont icon-arrow-right u-font-36"></text>
				</view>
			</view>
			<!-- <navigator url="/pages/invite/index/index" class="item u-m-t-30" v-if="!examine">
				<view class="icon">
					<text class="cuIcon-forward u-font-60 text-yellow"></text>
				</view>
				<view class="content">
					<view class="label">
						<text class="u-font-36 text-bold">邀请好友</text>
					</view>
					<view class="sub u-m-t-10">
						<text class="u-font-28">分享邀请更多好友</text>
					</view>
				</view>
				<view class="arrow">
					<text class="iconfont icon-arrow-right u-font-36"></text>
				</view>
			</navigator> -->
		</view>
	</view>
</template>

<script>
	import {mapGetters} from "vuex"
	import { scanCode } from "@/utils/file"
	export default {
		data() {
			return {
				
			}
		},
		computed:{
			...mapGetters('user',['userInfo']),
			...mapGetters('system',['examine']),
		},
		methods: {
			async scan(){
				const {result} = await scanCode({scanType:['qrCode']})
				if(/^API:/.test(result)){
					const [fun,pram] = result.slice(4).split('?')
					const pramObj = !!pram?pram.split('&').map(item=>item.split('=')).reduce((r,[k,v])=>{r[k]=v; return r},{}):undefined;
					this[fun]&&this[fun](pramObj)
				}
				if(/^PATH/.test(result)){ 
					const url = result.slice(5)
					uni.navigateTo({
						url
					})
				}
				if(/^login:qr:/.test(result)){
					const id = result.slice(9)
					uni.navigateTo({
						url:`/pages/login/scan?id=${id}`
					})
				}
			},
		}
	}
</script>
<style>
	page{
		background-color: #FFFFFF;
	}
</style>
<style lang="scss" scoped>
	.search-bar{
		background-color: #F1F1F1;
		border-radius: 20rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #aaaaaa;
	}
	.choice{
		margin: 100rpx 50rpx 0;
		.item{
			display: flex;
			align-items: center;
		}
		.icon{
			margin-right: 30rpx;
			flex-shrink: 0;
		}
		.content{
			flex: 1;
		}
		.arrow{
			flex-shrink: 0;
			color: #AAAAAA;
		}
	}
</style>
